package com.finalcial.Test;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import com.finalcial.dao.EchatsDao;


public class EchartsTest extends Junit4BaseTest {
	@Autowired 
	private EchatsDao echatsDao;
	
		
	
	@Test
	public void listEcharts(){
		
		Integer userId = 19005;
		List<Map<String, Object>> getReimbursementTypeName = echatsDao.getReimbursementTypeName(userId);
		//得到报销的时间 list
		List<Date> getReimbursementTime = echatsDao.getReimbursementTime(userId);
		//报销类型的名称
		String reimbursementTypeName = "";
		//存储国内差旅
		List<Map<String, Object>> listDomesticTravel = new ArrayList<Map<String,Object>>();
	    Map<String, Object> domesticTravelMap = new HashMap<String, Object>(); 
	    //员工福利
	    List<Map<String, Object>> listStaffForm = new ArrayList<Map<String,Object>>();
	    Map<String, Object> StaffFormMap = new HashMap<String, Object>(); 
	    //存储公务交通
	    List<Map<String, Object>> listOfficialTraffic = new ArrayList<Map<String,Object>>();
	    Map<String, Object> officialTrafficMap = new HashMap<String, Object>(); 
	    //存储物业管理
	    List<Map<String, Object>> listPropertyManager = new ArrayList<Map<String,Object>>();
	    Map<String, Object> propertyManagerMap = new HashMap<String, Object>(); 
	    
		for(Map<String, Object> map:getReimbursementTypeName) {//遍历list报销类型
			for(String reimbursementTypeNames :map.keySet()) {//得到每一个的报销类型
				//System.out.print(reimbursementTypeNames+":"+map.get(reimbursementTypeNames));
				reimbursementTypeName = (String) map.get(reimbursementTypeNames);//每一个报销类型的名称
				Integer getReimbursementMoney = 0;
				int count = 0;
				
				for(Date reimbursementTime:getReimbursementTime){//遍历时间
					
					//System.out.println(reimbursementTime);
					SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
			        String reimbursementTimes = dateFormat.format(reimbursementTime); //获得的date类型的值转成String类型
			        //得到每一个时间段，每一个报销类型的钱
			        getReimbursementMoney = echatsDao.getReimbursementMoney(userId, reimbursementTypeName, reimbursementTimes);
			        //System.out.println("==="+getReimbursementMoney);
					
					if("domesticTravel".equals(reimbursementTypeNames)){//国内差旅
						count++;
						domesticTravelMap.put(reimbursementTypeNames+count, getReimbursementMoney);
					}else if("staffForm".equals(reimbursementTypeNames)){//员工福利
						count++;
						StaffFormMap.put(reimbursementTypeNames+count, getReimbursementMoney);
					}else if("officialTraffic".equals(reimbursementTypeNames)){//公务交通
						count++;
						officialTrafficMap.put(reimbursementTypeNames+count, getReimbursementMoney);
					}else if("propertyManager".equals(reimbursementTypeNames)){//物业管理
						count++;
						propertyManagerMap.put(reimbursementTypeNames+count, getReimbursementMoney);
					}
					
					
				}
				
				
			}
			listDomesticTravel.add(domesticTravelMap);
			listStaffForm.add(StaffFormMap);
			listOfficialTraffic.add(officialTrafficMap);
			listPropertyManager.add(propertyManagerMap);
		}
		
		
	//	for(Map<String, Object> map:listDomesticTravel) {//遍历list报销类型
	//		for(String money :map.keySet()) {
	//			System.out.println(money+":"+map.get(money));
	//		}
	//	}
	//	for(Map<String, Object> map:listStaffForm) {//遍历list报销类型
	//		for(String money :map.keySet()) {
	//			System.out.println(money+"::"+map.get(money));
	//		}
	//	}
	//	for(Map<String, Object> map:listOfficialTraffic) {//遍历list报销类型
	//		for(String money :map.keySet()) {
	//			System.out.println(money+":::"+map.get(money));
	//		}
	//	}
	//	for(Map<String, Object> map:listPropertyManager) {//遍历list报销类型
	//		for(String money :map.keySet()) {
	//			System.out.println(money+"::::"+map.get(money));
	//		}
	//	}
	//	for(Date reimbursementTimess:getReimbursementTime){
	//		System.out.println("=="+reimbursementTimess);
	//	}
	
			
		
		
	}
	@Test
	public void test2(){
		Integer userId = 19001;
		List<String> listStart = echatsDao.getStartSection(userId);
		for(String start:listStart){
			System.out.println(start);
		}
	}
	
	@Test
	public void test3(){
		Integer userId = 19001;
		String businessTravelStartSection = "成都";
		List<String> lisrEnd = echatsDao.getEndSection(userId, businessTravelStartSection);
		for(String end:lisrEnd){
			System.out.println(end);
		}
	}
}
